<!--
 * @Author: 
 * @Date: 2021-12-27 21:07:24
 * @LastEditors: Joe Yan
 * @LastEditTime: 2021-12-27 21:11:05
 * @Description: file content
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        function isType(data, type) {
            const typeObj = {
                '[object String]': 'string',
                '[object Number]': 'number',
                '[object Array]': 'array',
            }

            let name = Object.prototype.toString.call(data);
            let typeName = typeObj[name];
            return typeName == type;
        }

        console.log(isType(123, 'number'));
        console.log(isType('1', 'number'));
        console.log(isType([12, 44], 'array'));
    </script>
</body>

</html>